﻿using ArtMath.AuxiliaryTool;
using ArtMath.Core.Data;
using ArtMath.PointCollection;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace ArtMath.Component.Annotation
{
    /// <summary>
    /// 区域橡皮
    /// </summary>
    public class RegionEraser : ToolBase
    {
        Curve cur = new Curve();
        public event Action<IList<PointD>> Erase;
        public RegionEraser(PointD initLocation)
        {
            cur.Add(initLocation);
        }
        public override void MouseMove(MouseMoveEventArgs e)
        {
            switch (e.Button)
            {
                case MouseButtons.Left:
                    cur.Add(e.CurrentPosition);
                    break;
            }
        }
        public override void Complete()
        {
            Erase?.Invoke(cur);
            base.Complete();
        }
        public override void Paint(Graphics gra)
        {
            Pen p = new Pen(Color.Red, 2) { DashStyle = DashStyle.Dash, LineJoin = LineJoin.Round };
            cur.Paint(gra, p);
            gra.DrawLine(p, cur[cur.Count - 1].ToPointF(), cur[0].ToPointF());
        }
    }
}
